package com.android.binderserverclient0.workmanager

import android.content.Context
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters

class DoWorker(context: Context, workerParameters: WorkerParameters) : Worker(context, workerParameters) {

    override fun doWork(): Result {
        try {
            Thread.sleep(3000)
        } catch (e: InterruptedException) {
            onStopped()
        }

        if (isStopped) {
            Log.d(TAG, "fun onStopped()")
            return Result.failure()
        }

        return Result.success()
    }

    override fun onStopped() {
        super.onStopped()
    }

    companion object {
        const val TAG = "DO_WORKER"
    }
}